<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>选择商品分类_<?=SITE_NAME?>_<?=$scfg['base']['title']?></title>
<meta name="keywords" content="<?=$scfg['base']['keywords']?>" />
<meta name="description" content="<?=$scfg['base']['description']?>" />
<script type="text/javascript">
try{document.domain="<?=SITE_DOMAIN?>";}catch (e){};
var __scfg__ = {
	staticUrl:"<?=surl::get("static");?>",
	thisPage:"my_sell"
};
</script>
<script type="text/javascript" src="<?=surl::get("static");?>www.js"></script>
<script type="text/javascript" src="<?=surl::get('my')?>cats.js.php"></script>

</head>
<body>
<? tpl::import('my/header.my.tpl.php');?>
<div id="Main">
  <div class="step">
    <ul style="width:420px;margin:0 auto;">
      <li class="stepFore"><span>1</span>选择出售方式</li>
      <li class="stepHere"><span>2</span>选择商品分类</li>
      <li><span>3</span>填写商品详情</li>
    </ul>
  </div>
  <div id="w760">
    <div class="warn">发布您的商品请先阅读，
            <a href="<?=$scfg['help']['gugao_estopsell']?>" target="_blank">禁止交易和限制交易的物品规则</a>，
            <a href="<?=$scfg['help']['gugao_to_duplicate']?>"  target="_blank">重复发布商品处理规则</a>。
    </div>
    <div class="history" style="display:none;">
      <div><b>曾经使用过的类目: </b><a href="#">清除曾用类目</a> </div>
      <div class="ResultDiv">
        <ul>
          <li>数码配件/电子元件 >> 手机配件及其它</li>
          <li>数码配件/电子元件 >> 手机配件及其它</li>
          <li>数码配件/电子元件 >> 手机配件及其它</li>
       </ul>
      </div>
    </div>
	<form name="cats" id="cats" method="get" action="sell.php">
    <div class="ClassListDiv">
      <div class="fontOrange b">请选择商品所在类目:</div>
      <input type="hidden" name="cSellType" value="<?=$cSellType?>" />
      <input type="hidden" name="id" value="<?=$id?>" />
	  <input type="hidden" name="step" value="info" />
      <ul id="sort">
        <li> 第一级类目<br />
          <select name="c1id" size="12"></select>
        </li>
        <li> 第二级类目<br />
          <select name="c2id" size="12"></select>
        </li>
        <li> 第三级类目<br />
          <select name="c3id" size="12"></select>
        </li>
        <li> 第四级类目<br />
          <select name="c4id" size="12"></select>
        </li>
      </ul>
    </div>
	<div class="next">
         <input id="next" type="submit"  value="下一步 &gt;&gt;" class="submitBtn"  onmouseover="this.className='submitBtnOver'" onmouseout="this.className='submitBtn'" onclick="doChkCats();" />
    </div>
	</form>
	<div class="fclear"></div>
    <form  onsubmit="return doSearch()">
      <div class="sortSearch" style="display:none;">
        <div><b>快速搜索类目：</b>
          <input name="ClassKeyWord" type="text" style="width:300px" />
          <input name="submit" type="button" value=" 搜 索 "  onclick="doSearch()" />
          &nbsp; <span class="fontGray">（点击搜索结果可快速定位所需类目）</span> </div>
        <div class="ResultDiv">
          <ul>
            <li>数码配件/电子元件 >> 手机配件及其它</li>
            <li>数码配件/电子元件 >> 手机配件及其它</li>
            <li>数码配件/电子元件 >> 手机配件及其它</li>
            <li>数码配件/电子元件 >> 手机配件及其它</li>
         </ul>
        </div>
      </div>
    </form>
  </div>
</div>
<script type="text/javascript">
var catCats =<?=json::encode($cats);?>;
var catSel=["c1id","c2id","c3id","c4id"];
var arrData=[];
function Init_upload(formName)
{
	var form = document.forms[formName],k,d,t;
	var t = arrData[0]=cats;
	var CurSelect= form.elements[catSel[0]];
	for(k in cats)
	{
		d = cats[k][0];
		//alert(d);
		SelectOption = new Option(d[0]+(d[1]==1?'->':''),d[2]);
		CurSelect.options[CurSelect.options.length] = SelectOption;
	}
	document.getElementById("next").disabled=true;
	//bind
	$("select",form).bind("change",function(){changeSort_upload(formName,this)});
	//接收初值
	updateSort_upload(formName,catCats.c1id,catCats.c2id,catCats.c3id,catCats.c4id);
}
function updateSort_upload(formName,g_c1id,g_c2id,g_c3id,g_c4id)
{
	var form = document.forms[formName],CurSelect;
	if(g_c1id)
	{
		CurSelect= form.elements[catSel[0]];
		CurSelect.value = g_c1id;
		changeSort_upload(formName,CurSelect);
		if(g_c2id)
		{
			CurSelect = form.elements[catSel[1]];
			CurSelect.value = g_c2id;
			changeSort_upload(formName,CurSelect);
			if(g_c3id)
			{
				CurSelect = form.elements[catSel[2]];
				CurSelect.value = g_c3id;
				changeSort_upload(formName,CurSelect);
				if(g_c4id)
				{
					CurSelect = form.elements[catSel[3]];
					CurSelect.value = g_c4id;
					changeSort_upload(formName,CurSelect);
				}
			}
		}
	}
}
function changeSort_upload(formName,selectObj)
{
	var selectNum = CheckSelectObj(selectObj,formName)+1;
	var form = document.forms[formName],k,d,t;
	var ts = arrData[selectNum]=arrData[selectNum-1][selectObj.value];
	var t = arrData[selectNum]=arrData[selectNum-1][selectObj.value][1];
	var CurSelect= form.elements[catSel[selectNum]];
	//CurSelect.options.length=0;
	for(k in t)
	{
		d = t[k][0];
		SelectOption = new Option(d[0]+(d[1]==1?'->':''),d[2]);
		CurSelect.options[CurSelect.options.length] = SelectOption;
	}
	document.getElementById("next").disabled= ts[0][1]==0?false:true;
}
function CheckSelectObj(selectObj,formName)
{
	var selectNum = -1;
	var name = selectObj.name;
	for (var i = 0; i < catSel.length; i++) 
	{
		if (catSel[i] == name) 
		{
			selectNum = i;
			break;
		}
	}
	for(i=catSel.length-1;i>selectNum;i--)
	{
		obj=document.forms[formName][catSel[i]];
		obj.options.length = 0; 
	}
	return selectNum ;
}
Init_upload('cats');
</script>
<? tpl::import('foot.tpl.php');?>
</body>
</html>
